#!/bin/sh

test -f /etc/config/independent && exit 0

local ifname=`uci get network.lan.ifname 2>/dev/null`
uci -q batch <<-EOT
	set network.wan=interface
	set network.wan.ifname="$ifname"
	set network.wan.proto='dhcp'
	set network.wan.metric='31'
	set network.wan6=interface
	set network.wan6.proto='dhcpv6'
	set network.wan6.ifname="$ifname"
	set network.wan6.reqaddress='try'
	set network.wan6.reqprefix='auto'
	set network.lan.ifname='none'
	set network.lan.ipaddr='192.168.0.1'
	set network.lan.netmask='255.255.255.0'
	add network device
	set network.@device[-1].name='macvlan0'
	set network.@device[-1].type='macvlan'
	set network.@device[-1].ifname="$ifname"
	set network.lan1=interface
	set network.lan1.proto='static'
	set network.lan1.ifname="macvlan0"
	set network.lan1.ipaddr='192.168.15.1'
	set network.lan1.netmask='255.255.255.0'
	commit network
	EOT

touch /etc/config/independent
exit 0
